package com.yungu.swift.order.model.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @author: cuixiuyin
 * @date: 2018/11/12 16:41
 */
public enum SecretReportEnum {

    /**
     * 隐私号码通话记录——释放原因
     */
    UNASSIGNED_NUMBER(1, "未分配的号码"),
    NO_ROUTE_NETWORK(2, "无路由到指定的转接网"),
    NO_ROUTE_DESTINATION(3, "无路由到目的地"),
    SEND_DEDICATED_MESSAGE(4, "发送专用信息音"),
    CALL_DISCONNECTION(16, "正常的呼叫拆线"),
    BUSY(17, "用户忙"),
    NO_RESPONSE(18, "用户未响应"),
    NO_ANSWERED(19, "用户未应答"),
    ABSENCE(20, "用户缺席"),
    CALL_REJECTION(21, "呼叫拒收"),
    NUMBER_CHANGE(22, "号码改变"),
    DESTINATION_UNREACHABLE(27, "目的地不可达"),
    INVALID_NUMBER(28, "无效的号码格式（地址不全）"),
    PERFORMANCE_REJECTION(29, "性能拒绝"),
    UNSPECIFIED(31, "正常—未指定"),
    PATH_NOT_AVAILABLE(34, "无电路/通路可用"),
    DEVICE_CONGESTION(42, "交换设备拥塞"),
    PERFORMANCE_NOT_SCHEDULED(50, "所请求的性能未预定"),
    RESTRICT_CALL(53, "CUG中限制去呼叫"),
    RESTRICTED_CALL(55, "CUG中限制来呼叫"),
    NO_CAPACITY(57, "承载能力无权"),
    UNAVAILABLE_CAPACITY(58, "承载能力目前不可用"),
    NO_IMPLEMENTED_CAPACITY(65, "承载能力未实现"),
    NO_IMPLEMENTED_PERFORMANCE(69, "所请求的性能未实现"),
    NO_MENBER(87, "被叫用户不是CUG的成员"),
    INCOMPATIBLE(88, "不兼容的目的地"),
    NO_PRESENCE(90, "不存在的CUG"),
    INVILID_NETWORK_SELECTION(91, "无效的转接网选择"),
    INVILID_MESSAGE(95, "无效的消息，未指定"),
    NO_MESSAGE_TYPE(97, "消息类型不存在或未实现"),
    NO_PARAMETER(99, "参数不存在或未实现"),
    SCHEDULE_RECOVER(102, "定时器终了时恢复"),
    NO_IMPLEMENTED(103, "参数不存在或未实现—传递"),
    INVALID_PARAMETER(110, "消息带有未被识别的参数—舍弃"),
    PROTOCOL_ERROR(111, "协议错误，未指定"),
    INTERWORKING(127, "互通，未指定"),
    ;

    private int code;
    private String msg;

    SecretReportEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * key:code
     * value:msg
     */
    private static Map<Integer, String> MAP = new HashMap<>(16);

    public static String getReleaseCause(Object code) {
        if (MAP == null || MAP.size() == 0) {
            SecretReportEnum[] secretReportEnums = SecretReportEnum.values();
            for (SecretReportEnum secretReportEnum : secretReportEnums) {
                MAP.put(secretReportEnum.code, secretReportEnum.msg);
            }
        }
        return MAP.get(code);
    }
}
